<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-trophy"></i> 组织管理
            </div>
            <div class="box-tools pull-right">

                <a href="javascript:;" onclick="vLayuiUtil.openLayerMaxWindow('vOrganization', '<c:url
                        value="/web/admin/organization/viewTree.action"/>','查看结构')" class="btn btn-default btnTool"
                   title="新增用户"><i class="fa fa-plus"></i> 查看结构</a>
                <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
                <a href="javascript:;" onclick="vLayuiUtil.openLayerWindow('wOrganization', '<c:url
                        value="/web/admin/organization/editPage.action"/>','新增')" class="btn btn-default btnTool"
                   title="新增用户"><i class="fa fa-plus"></i> 新增</a>

            </div>
        </div>
        <div class="box-body">
            <form id="searchForm" action="<c:url value="/web/admin/organization/listJson.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <div class="form-group">
                    <label class="control-label">搜索：</label>
                    <div class="control-inline">
                        <input type="text" id="organizationName" name="organizationName" value="" placeholder="组织名称" maxlength="64"
                               class="form-control width-120">
                        <input type="text" id="code" name="code" value="" placeholder="组织编码" maxlength="64"
                               class="form-control width-120">
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">查询</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                </div>
            </form>

            <table id="organizationGrid"></table>
            <div id="organizationGridPage"></div>
        </div>
    </div>
</div>
<script>
    $('#organizationGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header: '关键字', name: 'id', index: 'id', width: 50, align: "center"},
            {header: '组织名称', name: 'organizationName', index: 'organizationName', width: 200, align: "center"},
            {header: '组织简介', name: 'organizationDesc', index: 'organizationDesc', width: 100, align: "center"},
            {header: '等级', name: 'lvl', index: 'lvl', width: 100, align: "center"},
            {header: '所属企业', name: 'enterpriseName', index: 'enterpriseName', width: 100, align: "center"},

            {
                header: '操作',
                name: 'actions',
                width: 60,
                sortable: false,
                title: false,
                formatter: function (val, obj, row, act) {
                    return '<a  class="btnList" onclick="editOrganization(' + row.id + ')" title="编辑部门"><i class="fa fa-pencil"></i></a>&nbsp;'+
                        '<a  class="btnList" onclick="editChildOrganization(' + row.id + ')" title="编辑部门"><i class="fa fa-plus-square"></i></a>&nbsp;'
                }
            }
        ],
        // 加载成功后执行事件
        ajaxSuccess: function (data) {

        }
    });

    function editOrganization(id) {
        vLayuiUtil.openLayerWindow('wOrganization', '<c:url
                        value="/web/admin/organization/editPage.action?id="/>' + id, '编辑')
    }
    function editChildOrganization(id) {
        vLayuiUtil.openLayerMaxWindow('wChildOrganization', '<c:url
                        value="/web/admin/organization/editChildPage.action?id="/>' + id, '编辑子组织信息')
    }
</script>